package cn.bdqn.pn.reposity.base;

import cn.bdqn.pn.pojo.base.City;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;


/**
 * 城市
 */

public interface CityRepository extends JpaRepository<City, Integer>, JpaSpecificationExecutor<City> {
    @Query(value = "select * from City where fatherId>0 order by ?#{#pageable}"
            ,countQuery = "select count(*) from city where fatherId>0"
            ,nativeQuery = true)
    Page<City> listAllCity(Pageable pageable);


    /**
     *
     *
     * ----------------cp
     * 根据城市Id查询城市信息
     * @param cityId
     * @return
     */
    City findCityByCityId(Integer cityId);
}
